package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.OrganizationTypeDao;
import com.hy.erp.inventory.dao.PositionDao;
import com.hy.erp.inventory.dao.interfaces.IOrganizationTypeDao;
import com.hy.erp.inventory.pojo.Organisation;
import com.hy.erp.inventory.pojo.OrganizationType;
import com.hy.erp.inventory.pojo.interfaces.IOrganisation;
import com.hy.erp.inventory.pojo.interfaces.IOrganizationType;
import com.hy.erp.inventory.service.interfaces.IOrganizationTypeService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午10:55:41</li>
 * <li>类型名称：OrganizationTypeService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "organizationTypeService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless*/
@Component("organizationTypeService")

public class OrganizationTypeService extends AbstractBusinessService < OrganizationTypeDao> implements IOrganizationTypeService
{
	
	
	private IOrganizationTypeDao organizationTypeDao=null;
					
	@Resource(name="organizationTypeDao")
	public void setPositionTypeDao(IOrganizationTypeDao organizationTypeDao) {
		this.organizationTypeDao = organizationTypeDao;
	}

	@ Override
	public boolean addOrganizationType (
											OrganizationType organizationType )
	{






		if ( null == organizationType )
		{
			return true ;
		}

		else
		{
			//System.out
			//			.println ( "ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh" ) ;

			//IOrganizationTypeDao organizationTypeDao =
			//									( IOrganizationTypeDao ) this
			//																.getDao ( IOrganizationType.class ) ;

			return organizationTypeDao
									.persist ( organizationType ) ;
		}

	
	
	
	
	
	}

	@ Override
	public boolean modifyOrganizationType (
										OrganizationType organizationType )
	{






		if ( ( null == organizationType )
				|| ( null == organizationType
											.getIdentifier ( ) )
				|| ( organizationType
									.getIdentifier ( )
									.trim ( )
									.length ( ) == 0 ) )
		{
			return true ;
		}
		else
		{

			///IOrganizationTypeDao organizationTypeDao =
			//	( IOrganizationTypeDao ) this
			//								.getDao ( IOrganizationType.class ) ;



			if ( null == organizationType )
			{
				throw new ArchitectureFoundationException (
															"修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}

			return ( organizationTypeDao
									.merge ( organizationType ) != null ) ;
		}

	
	
	
	
	
	}

	@ Override
	public Integer removeOrganizationType (
											String [ ] organizationTypeIds )
	{



		if ( ( null == organizationTypeIds )
				|| ( organizationTypeIds.length == 0 ) )
		{
			return new Integer (
									0 ) ;
		}
		else
		{

			//IOrganizationTypeDao organizationTypeDao =
			//	( IOrganizationTypeDao ) this
			//								.getDao ( IOrganizationType.class ) ;


			return organizationTypeDao
									.remove ( organizationTypeIds ) ;
	}
	
	
	
	
	}

	@ Override
	public String [ ] addOrganizationType (
											Object [ ] objects )
	{
		//IOrganizationTypeDao organizationTypeDao =
		//	( IOrganizationTypeDao ) this
		//								.getDao ( IOrganizationType.class ) ;
		OrganizationType[] types=new OrganizationType[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			OrganizationType type=( OrganizationType ) objects[i];
			types[i]=type;
		}
		return organizationTypeDao.persist ( types ) ;
	}

	@ Override
	public List < Organisation > getAllOrganisation ( )
	{
		//IOrganizationTypeDao organizationTypeDao =
		//	( IOrganizationTypeDao ) this
		//								.getDao ( IOrganizationType.class ) ;

		//return organizationTypeDao.find ( ) ;
		throw new RuntimeException("sssssssssssssssssssssssss");
	}

	@ Override
	public String [ ] modifyOrganizationType (
												Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
		//	IOrganizationTypeDao organizationTypeDao =
		//		( IOrganizationTypeDao ) this
			//								.getDao ( IOrganizationType.class ) ;
			OrganizationType[] types=new OrganizationType[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	OrganizationType type=( OrganizationType ) objects[i];
            	types[i]=type;
            }
			
			return organizationTypeDao.merge ( types );
		}
	}

	@Override
	public List<OrganizationType> getAllOrganizationType() {
		return organizationTypeDao.find();
	}

}
